package com.app.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @author by jt
 * 用户表
 */
@Data
@Accessors(chain = true)
public class User implements UserDetails {
    @TableId(type = IdType.AUTO)
    private Integer id;   //主键
    private String username;
    private String password;
    private String tel;
    private Character state;   //0可用 1新申请 2 不可用
    private String url;
    private Character sex;
    private String idCard;
    private Character rid; //用户角色
    /**
     * 车牌号
     */
    private String carNum;

    /**
     * 管理科目
     */
    private Character manSubject;
    /**
     * 目前考试进度
     */
    private Character testStatus; //考试进度现在在考科目几
    /**
     * 综合得分
     */
    private String score;

    private Character testState; //申请考试状态     0是没有申请  1申请中

    @Override
    @JSONField(serialize = false)
    public Collection<? extends GrantedAuthority> getAuthorities() {

        return null;  //用于角色身份
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    @JSONField(serialize = false)
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    @JSONField(serialize = false)
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    @JSONField(serialize = false)
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    @JSONField(serialize = false)
    public boolean isEnabled() {
        return true;
    }
}
